VPATH = src:src/bsdfs:src/materials:src/math:src/shapes:src/utils:src/3rdParty/pugixml-1.7
vpath %.hpp src:src/bsdfs:src/materials:src/math:src/shapes:src/utils
#INCLUDE  = -I3rdParty/boost_1_60_0
INCLUDE  = -Isrc/3rdParty/pugixml-1.7
INCLUDE += -Isrc
INCLUDE += -Isrc/bsdfs
INCLUDE += -Isrc/materials
INCLUDE += -Isrc/math
INCLUDE += -Isrc/shapes
INCLUDE += -Isrc/utils

CFLAGS  = -std=c++11 -O2 -DNDEBUG 
CFLAGS +=-DMULTI_THREAD

OBJDIR = ./temp/
BINDIR = ./bin/
objects  = main.o AABB.o BxDF.o Camera.o Color.o Canvas.o HitInfo.o Integrator.o \
		Light.o Material.o Ray.o Renderer.o Sample.o Scene.o Shape.o Texture.o Transform.o \
		pugixml.o KDTree.o Primitive.o
		
objects += Log.o Params.o Timer.o FileManager.o
objects += Math.o RNG.o
objects += Disk.o Plane.o Sphere.o TriangleMesh.o
objects += Fresnel.o
objects += GlassMaterial.o MatteMaterial.o MirrorMaterial.o PlasticMaterial.o MetalMaterial.o
CC = g++

OBJS = $(addprefix $(OBJDIR), $(objects))

all : temp bin RayTracer

temp:
	mkdir -p ./temp

bin:
	mkdir -p /bin

RayTracer: $(OBJS)
	$(CC) $^ -o $(BINDIR)$@

$(OBJDIR)%.o: %.cpp $(OBJDIR)%.d
	$(CC) $(INCLUDE) $(CFLAGS) -c $< -o $@

$(OBJDIR)%.d : %.cpp
	@set -e; rm -f $@; \
	$(CC) -MM $< $(INCLUDE) $(CFLAGS) > $@.$$$$; \
	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
	rm -f $@.$$$$

-include $(objects:.o=.d)

.PHONY: clean
clean:
	rm -rf $(OBJDIR) $(BINDIR)ray_tracer *.d *.d.*
